
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

#include <BLineEdit>
#include <BTextEdit>
#include <BLabel>
#include <BButton>
#include <BScrollArea>
#include <BScrollWidget>
#include <BListWidget>
#include <BListItem>
#include <BProgressBar>
#include <BComboBox>
#include <BTableWidget>
#include <BTableItem>
#include <BScrollWidget>
#include <BScrollBar>
#include <BTreeWidget>
#include <BHtmlWidget>
#include <BStyle>
#include <BGridLayout>
#include <BHBoxLayout>
#include <BVBoxLayout>
#include <BGroupBox>
#include <BXmlNode>
#include <BSonNode>
#include <BMenu>
#include <BMainWindow>

#include "StyleFormat.h"

using namespace BWE;

class MainWindow : public BMainWindow
{
public:
	MainWindow();
	~MainWindow();

	bool openFile(const BString& fileName);

protected:
	BTreeItem* createTreeItem(BXmlNode* node);
	BTreeItem* createTreeItem(BSonNode* node);
	bool assignIcon(BTreeItem* item);
	BTreeItem* createTreeItem(BStyle* style);

	static BString StyleName(int name);
	static BString valueToString(const BValue& value);

protected:
	void slotFileButtonClicked(BObject* object);

	void slotItemDoubleClicked(BObject* object, const BValue& value);
	void slotItemTextEdited(BObject* object, const BValue& value);
	void slotItemTextEditFocusOut(BObject* object);
	void slotPolicyButtonClicked(BObject* object, const BValue& value);
	void slotPolicyMenuTrigger(BObject* object, const BValue& value);

	void slotSheetFileNameChanged();
	void slotOpenFileButtonClicked();
	void slotResetButtonClicked();
	void slotSaveSheetButtonClicked();
	void slotSheetTextEdited(BObject* object, const BValue& value);
	void slotTreeItemSelected(BObject* object, const BValue& value);

protected:
	virtual void showEvent(const BEvent& event);

	virtual void styleEvent(const BEvent& event);

private:
	BLineEdit*		_fileNameEdit;
	BButton*		_openFileButton;
	BButton*		_resetFileButton;
	BButton*		_saveFileButton;

	BTreeWidget*	_treeWidget;
	BTextEdit*		_textEdit;
	BTableWidget*	_tableWidget;

	BIconHolder		_rootIcon;
	BIconHolder		_subsIcon;
	BIconHolder		_itemIcon;
};

#endif